package com.zoiz.util;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;


import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.zoiz.plus.extend.DBException;

public class Configurations {
	private static DataSource cpds;

	/**
	 * 获取连接池链接
	 * @return
	 */
	public static Connection getConnection() {
		if (cpds == null) {
			throw new DBException("c3p0 未初始化！");
		}
		try {
			return cpds.getConnection();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw new DBException(e);
		}
	}
	
	public static void setDs(DataSource c){
		cpds=c;
	}
}
